package Stack;


import java.util.ArrayDeque;
import java.util.Deque;

/**
 * @BelongsProject: SeniorArchitect-LeetCode
 * @BelongsPackage: Stack
 * @Author: zhuangxiaoyan
 * @CreateTime: 2023-10-21  10:20
 * @Description: TODO
 * @Version: 1.0
 */
public class 股票跨度901 {

    Deque<int[]> stack;
    int idx;

    public 股票跨度901() {
        stack = new ArrayDeque<int[]>();
        stack.push(new int[]{-1, Integer.MAX_VALUE});
        idx = -1;
    }

    public int next(int price) {
        idx++;
        while (price >= stack.peek()[1]) {
            stack.pop();
        }
        int ret = idx - stack.peek()[0];
        stack.push(new int[]{idx, price});
        return ret;
    }

    public static void main(String[] args) {
        股票跨度901 a = new 股票跨度901();
        int next = a.next(100);
        int next2 = a.next(80);
        int next3 = a.next(60);
        int next4 = a.next(70);
        int next5 = a.next(60);
        int next6 = a.next(75);
        int next7 = a.next(85);
        System.out.println(next);
        System.out.println(next2);
        System.out.println(next3);
        System.out.println(next4);
        System.out.println(next5);
        System.out.println(next6);
        System.out.println(next7);
    }
}
